package edu.iss.demo.model;

import java.io.Serializable;
import javax.persistence.*;
import java.util.List;


/**
 * The persistent class for the leave_type database table.
 * 
 */
@Entity
@Table(name="leave_type")
@NamedQuery(name="LeaveType.findAll", query="SELECT l FROM LeaveType l")
public class LeaveType implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@Column(name="leave_code")
	private String leaveCode;

	private String description;

	@Column(name="leave_type")
	private String leaveType;

	@Column(name="num_of_day")
	private int numOfDay;

	//bi-directional many-to-one association to LeaveApplication
	@OneToMany(mappedBy="leaveType")
	private List<LeaveApplication> leaveApplications;

	public LeaveType() {
	}

	public String getLeaveCode() {
		return this.leaveCode;
	}

	public void setLeaveCode(String leaveCode) {
		this.leaveCode = leaveCode;
	}

	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public String getLeaveType() {
		return this.leaveType;
	}

	public void setLeaveType(String leaveType) {
		this.leaveType = leaveType;
	}

	public int getNumOfDay() {
		return this.numOfDay;
	}

	public void setNumOfDay(int numOfDay) {
		this.numOfDay = numOfDay;
	}

	public List<LeaveApplication> getLeaveApplications() {
		return this.leaveApplications;
	}

	public void setLeaveApplications(List<LeaveApplication> leaveApplications) {
		this.leaveApplications = leaveApplications;
	}

	public LeaveApplication addLeaveApplication(LeaveApplication leaveApplication) {
		getLeaveApplications().add(leaveApplication);
		leaveApplication.setLeaveType(this);

		return leaveApplication;
	}

	public LeaveApplication removeLeaveApplication(LeaveApplication leaveApplication) {
		getLeaveApplications().remove(leaveApplication);
		leaveApplication.setLeaveType(null);

		return leaveApplication;
	}

}